# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Co-Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>

pkgname=python-prctl
pkgver=1.8.1
pkgrel=5
pkgdesc='Python(ic) interface to the linux prctl syscall'
arch=('loong64' 'x86_64')
license=('GPL')
url='https://github.com/seveas/python-prctl'
depends=('python' 'libcap')
makedepends=('python-setuptools')
checkdepends=('iputils' 'procps-ng')
source=("$pkgname-$pkgver.tar.gz::https://github.com/seveas/python-prctl/archive/v$pkgver.tar.gz"
        "$pkgname-kernel-5.10.patch::https://github.com/seveas/python-prctl/pull/33.patch"
        "skip-tests.diff"
        "setuptools-62.1.diff")
sha512sums=('a251b0aefbd6a16d69fd664cadf87ba16af87e7551ae474846858876007028c13b619e227518688e876f95726d327eb4793c37a34317ec8a1bf2c6ea02a31b21'
            '839bd732ebe4318dd11a2f0037fd60e6b79de84374ef575278cd787eac87c19b00290f5871e70ebb14301fb8a7eb2dc718a754290285cc6f2e9abe6ef161b802'
            'd7aa5bf2a1854892d2a62fd78f713e6a9df5ff7b6d44a676316970dba348590151d6db5e0583d039db816d361793c8d2f143836bd4113f881e823c741f462bed'
            '7ad2c724860db6c8d3b4e767696e18cedd96a567a97ad14ac2dc29d0bb2f0dc01961775b6dac704dfcee6b00db89b9768f99dc0e68cdbf09ddc0ba4e1027a81a')

prepare() {
  cd python-prctl-$pkgver
  patch -Np1 -i ../$pkgname-kernel-5.10.patch
  patch -Np1 -i ../skip-tests.diff
  # Adapt for https://github.com/pypa/distutils/pull/133
  patch -Np1 -i ../setuptools-62.1.diff
}

build() {
  cd python-prctl-$pkgver
  python setup.py build
}

check() {
  cd python-prctl-$pkgver
  PYTHONDONTWRITEBYTECODE=1 python -m unittest discover
}

package() {
  cd python-prctl-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}
